package com.nmsl.nurse.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.nmsl.nurse.domain.MBedInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.nmsl.common.annotation.Log;
import com.nmsl.common.core.controller.BaseController;
import com.nmsl.common.core.domain.AjaxResult;
import com.nmsl.common.enums.BusinessType;
import com.nmsl.nurse.service.IMBedInfoService;
import com.nmsl.common.utils.poi.ExcelUtil;
import com.nmsl.common.core.page.TableDataInfo;

/**
 * 病床管理Controller
 * 
 * @author ruoyi
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/nurse/bed")
public class MBedInfoController extends BaseController
{
    @Autowired
    private IMBedInfoService bedInfoService;

    /**
     * 查询病床管理列表
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:list')")
    @GetMapping("/list")
    public TableDataInfo list(MBedInfo MBedInfo)
    {
        startPage();
        List<MBedInfo> list = bedInfoService.selectBedInfoList(MBedInfo);
        return getDataTable(list);
    }

    /**
     * 导出病床管理列表
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:export')")
    @Log(title = "病床管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MBedInfo MBedInfo)
    {
        List<MBedInfo> list = bedInfoService.selectBedInfoList(MBedInfo);
        ExcelUtil<MBedInfo> util = new ExcelUtil<MBedInfo>(MBedInfo.class);
        util.exportExcel(response, list, "病床管理数据");
    }

    /**
     * 获取病床管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:query')")
    @GetMapping(value = "/{bedId}")
    public AjaxResult getInfo(@PathVariable("bedId") Long bedId)
    {
        return success(bedInfoService.selectBedInfoByBedId(bedId));
    }

    /**
     * 新增病床管理
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:add')")
    @Log(title = "病床管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MBedInfo MBedInfo)
    {
        return toAjax(bedInfoService.insertBedInfo(MBedInfo));
    }

    /**
     * 修改病床管理
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:edit')")
    @Log(title = "病床管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MBedInfo MBedInfo)
    {
        return toAjax(bedInfoService.updateBedInfo(MBedInfo));
    }

    /**
     * 删除病床管理
     */
    @PreAuthorize("@ss.hasPermi('nurse:bed:remove')")
    @Log(title = "病床管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bedIds}")
    public AjaxResult remove(@PathVariable Long[] bedIds)
    {
        return toAjax(bedInfoService.deleteBedInfoByBedIds(bedIds));
    }


    @PreAuthorize("@ss.hasPermi('nurse:bed:list')")
    @GetMapping("/list/all")
    public TableDataInfo listall(MBedInfo MBedInfo)
    {
        startPage();
        List<MBedInfo> list = bedInfoService.selectBedAndWard(MBedInfo);
        return getDataTable(list);
    }


}
